import {messages} from "share/common";
import React from 'react'
import { connect } from 'react-redux'
import { Form, Badge, Alert } from 'antd'
const FormItem = Form.Item;
import constants from 'share/constants'
import Condition from 'components/condition'
const If = Condition.If;

class CreditEventCancelDetail extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  render(){
    const { data } = this.props;
    const formItemLayout = {
      labelCol: { span: 8 },
      wrapperCol: { span: 10, offset: 1 },
    };
    return (
      <div>
        <Alert
          message={messages('common.help')/*提示信息*/}
          description={messages('credit-setting.key1')/*一个信用事件可有多个事由。*/}
          type="info"
          showIcon
          style={{ marginBottom: 24 }}
        />
        <FormItem {...formItemLayout} label={messages('credit-setting.key2')/*信用人*/}>
          {data.fullName}
        </FormItem>
        <FormItem {...formItemLayout} label={messages('credit-setting.key3')/*信用类型*/}>
          报销信用
        </FormItem>
        <FormItem {...formItemLayout} label={messages('credit-setting.key4')/*相关单据*/}>
          {data.businessCode}
        </FormItem>
        <FormItem {...formItemLayout} label={messages('credit-setting.key5')/*事件描述*/}>
          {data.comment}
        </FormItem>
        <FormItem {...formItemLayout} label={messages('credit-setting.key6')/*信用规则*/}>
          {data.ruleCondition}
        </FormItem>
        <FormItem {...formItemLayout} label={messages('credit-setting.key7')/*处理方式*/}>
          {constants.getTextByValue(data.operationType, 'creditRuleOperation')}
        </FormItem>
        <FormItem {...formItemLayout} label={messages('credit-setting.key8')/*处理结果*/}>
          {`${data.operationType % 2 === 0 ? '-' : '+'}${data.operationType > 1002 ? data.changeRank : data.changeScore}`}
        </FormItem>
        <If value={data.status === 1002}>
          <FormItem {...formItemLayout} label={messages('common.column.status')/*状态*/}>
            <Badge status='error' text={messages('credit-setting.key9')/*作废*/}/>
          </FormItem>
          <FormItem {...formItemLayout} label={messages('credit-setting.key10')/*作废理由*/}>
            {data.cancelReason}
          </FormItem>
          <FormItem {...formItemLayout} label={messages('credit-setting.key11')/*处理人*/}>
            {data.operatorName}
          </FormItem>
        </If>
      </div>
    )
  }

}

function mapStateToProps(state) {
  return {
    user: state.login.user
  }
}

export default connect(mapStateToProps)(CreditEventCancelDetail);
